

import tushare as ts
from constants import TOKEN

TOKEN = '3e77f0822f8f7ecea13232ea81541b7cdf4a674273a57a4e0da0ef0a'
FORMAT_DAY = "%Y%m%d"
DATA_LONG = 30


def get_daily(ts_code, start_date:str, end_date:str):
    """获取日交易数据
    """
    pro = ts.pro_api(TOKEN)
    df = pro.daily(ts_code=ts_code, start_date=start_date, end_date=end_date)
    return df



def get_all_stock():
    """查询当前所有正常上市交易的股票列表
    """
    fields_columns = 'ts_code,symbol,name,area,industry,market,list_date'
    pro = ts.pro_api(TOKEN)
    data = pro.stock_basic(exchange='', list_status='L', fields=fields_columns)
    return data


def get_trade_cal(start_date, end_date, exchange=''):
    """获取交易日历
    """
    pro = ts.pro_api(TOKEN)
    df = pro.trade_cal(exchange=exchange, start_date=start_date, end_date=end_date)
    return df
